package grex.Nodes;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
import grex.Data.PredictionContainer;
public class Or extends Node {
  private static final int NROFCILDREN=2;
  public Or(){
    super(NROFCILDREN);
  }

    public synchronized void execute(Node parent, PredictionContainer data, int mode) throws GeneException {
        this.parent = parent;
        Node[] childs = this.getChildren();
        PredictionContainer lResult = data;
        PredictionContainer rResult = data.clone();
        childs[0].execute(this, lResult, mode);
        childs[1].execute(this, rResult, mode);
        for (double[] key : data.keySet()) {
            if (lResult.get(key).getCondition() || rResult.get(key).getCondition()) {
                data.get(key).setPrediction(1);
            } else {
                data.get(key).setPrediction(0);
            }

        }
        
    }

  public Object clone() {
    Or newOr = new Or();
    newOr.setOptions(ops);
    cloneChildren(newOr);
    newOr.setParent(parent);
    newOr.environment=environment;
    return newOr;
  }


  public String toString(){
    return "Or";
  }

}
